/**
 * The base for Multichannel JavaScript
 * mc.base.js
 */
 
 ( function( $ ) {

	if( typeof(MC) == 'undefined' ){
		MC = function(){
			return
		};
	};

	MC.utils = {
			
			_cookie : {
				// default the expiration date is one year from current
				currentDate : new Date(),
				calcExpiration : function( current ){
					var expiration = new Date();
					expiration.setTime( current.getTime() + 1000 * 60 * 60 * 24 * 365 )			
					return expiration
				},
				set : function( name , value ){
					document.cookie = name + "=" + value + "; expires=" + MC.utils._cookie.calcExpiration( MC.utils._cookie.currentDate ) + "; path=/";
					return
				},
				get : function( name ){
					var cookies = document.cookie.split(";"),
						cookiesLength = cookies.length;
						cookieName = name+"="
					for ( var i = 0; i < cookiesLength; i++ ){
						//console.log( cookies[i] );
						if( cookies[i].trim().indexOf(cookieName) == 0 ){
							MC.storeSelector.locationValues = $.parseJSON(cookies[i].trim().slice( cookieName.length ))
						}
					}
					return MC.storeSelector.locationValues;
				}				
			},
			
			//Tests for empty object
			_isEmpty : function( obj ){
				for( var i in obj ){ return false };
				return true
			},
			
			// _RemoveArrayItem
			// remove the second item from the array - array.remove( 1 );
			// remove the second-to-last item from the array - array.remove( -2 );
			// remove the last and second-to-last items from the array - array.remove( -2 ,-1 );
			_RemoveArrayItem : function( array , from , to ){
				var rest = array.slice((to || from) + 1 || array.length);
				array.length = from < 0 ? array.length + from : from;
				return array.push.apply( array , rest );
			}

	};

	
})( jQuery );